using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class SettingUI : MonoBehaviour
{
    [SerializeField] private Toggle musicToggle;
    [SerializeField] private Toggle soundToggle;
    [SerializeField] private Slider musicSlider;
    [SerializeField] private Slider soundSlider;
    [SerializeField] private SettingSO settingSO;
    void Start()
    {
        musicSlider.onValueChanged.AddListener((value) =>
        {
            settingSO.musicVolume = value;
        });
        soundSlider.onValueChanged.AddListener((value) =>
        {
            settingSO.soundVolume = value;
        });

        musicToggle.onValueChanged.AddListener((value) =>
        {
            settingSO.isMusicOn = value;
        });
        soundToggle.onValueChanged.AddListener((value) =>
        {
            settingSO.isSoundOn = value;
        });
        UpdatePanel();
    }

    void UpdatePanel()
    {
        musicToggle.isOn = settingSO.isMusicOn;
        soundToggle.isOn = settingSO.isSoundOn;
        musicSlider.value = settingSO.musicVolume;
        soundSlider.value = settingSO.soundVolume;
    }
}
